<template>
  <view class="index">
    <view class="jtop">
      <view class="status_bar"><!-- 这里是状态栏 --></view>
      <view class="jtop_l" @tap="navigateBack"
        ><image src="../../static/img/ic_back.png"></image
      ></view>
      <!-- <view class="jtop_l" @tap="navigateBack">关闭</view> -->
      <view class="jtop_c">新增会议纪要</view>
      <view class="jtop_r" @click="jsave">确定</view>
    </view>
    <view class="tophr"></view>

    <view class="addb">
      <view class="addb_1"> {{ jt }} {{ xq }} </view>
      <!-- <view class="addb_2">
				天气：晴
			</view>
			<view class="addb_2">
				温度：20~30℃
			</view> -->
    </view>
    <view class="addb">
      <view class="addi2">
        <text>会议主题</text>
        <input
          type="text"
          placeholder="请输入会议主题"
          :value="subject"
          @input="onKeyInput_o"
          placeholder-style="color:#CCCCCC"
        />
      </view>
      <view class="addi2">
        <text>会议地点</text>
        <input
          type="text"
          placeholder="请输入会议地点"
          :value="address"
          @input="onKeyInput_t"
          placeholder-style="color:#CCCCCC"
        />
      </view>

      <view
        class="addbi addi2"
        v-for="(item, index) in list"
        :key="index"
        :class="index == 1 ? 'noborder' : ''"
      >
        <text class="cell-title">
          {{ item.title }}
        </text>
        <input
          type="text"
          :placeholder="item.title2"
          :value="item.detail"
          disabled
          placeholder-style="color:#CCCCCC"
          @click="selectDatePicker(item.type, index)"
        />
        <image src="../../static/img/jt.png"></image>
      </view>

      <date-time-picker
        ref="date-time"
        :indicatorStyle="indicatorStyle"
        :type="type"
        :datestring="dateString"
        @change="dateTimeChange"
        style="margin:0"
      ></date-time-picker>
    </view>

    <view class="addb">
      <view class="addi2">
        <text>与会名单</text>
        <input
          type="text"
          placeholder="请输入与会人员"
          :value="participants"
          @input="onKeyInput_c"
          placeholder-style="color:#CCCCCC"
        />
      </view>
      <!-- 	<view class="addi2">
				<text>记录人员</text>
				<input type="text" placeholder="请输入姓名"  :value="name" @input="onKeyInput_f" placeholder-style="color:#CCCCCC"/>
			</view> -->
    </view>

    <view class="addi">
      <text>会议内容</text>
      <textarea
        auto-height="true"
        style="min-height: 150rpx;"
        maxlength="-1"
        placeholder-style="color:#CCCCCC"
        :value="content"
        @input="onKeyInput_i"
        placeholder="请输入会议内容"
      />
    </view>

    <view class="addi">
      <text>会议结论</text>
      <textarea
        auto-height="true"
        style="min-height: 150rpx;"
        maxlength="-1"
        placeholder-style="color:#CCCCCC"
        :value="conclusion"
        @input="onKeyInput_l"
        placeholder="请输入会议结论"
      />
    </view>
  </view>
</template>

<script>
import request from '@/common/request.js';
import { mapState } from 'vuex';
import DateTimePicker from '@/components/bory-dateTimePicker/bory-dateTimePicker.vue';
export default {
  data() {
    return {
      dateString: '',
      type: 'hour-minute',
      list: [
        {
          type: 'hour-minute',
          title: '开始时间',
          title2: '请输入开始时间',
          detail: '',
        },
        {
          type: 'hour-minute',
          title: '结束时间',
          title2: '请输入结束时间',
          detail: '',
        },
      ],

      repeat_click: true,
      ashowpop: false,
      ashowpop_jrename: false,
      ashowpop_jdel: false,
      ashowpopT: false,
      bj: false,
      yd: false,
      beginDate: '',
      endDate: '',

      address: '',
      beginTime: '',
      conclusion: '',
      content: '',
      endTime: '',
      id: '',
      participants: '',
      subject: '',

      jt: '',
      xq: '',
      date: '',
      city: '',
      tq: '',
      wd: '',
    };
  },
  components: {
    DateTimePicker,
  },
  onLoad() {
    this.jc = uni.getStorageSync('jc');
    console.log('ccccc:', this.jc);

    // this.name = this.jc.name;
    // this.content = this.jc.content;
    // this.id = this.jc.id;
    // this.leader = this.jc.leader;
    // this.number = this.jc.number;

    this.jt = uni.getStorageSync('jt');
    this.xq = uni.getStorageSync('week');

    this.adate = uni.getStorageSync('rq');
    var jd = {};
    jd.date = this.adate;
  },

  methods: {
    selectDatePicker(type, index) {
      this.type = type;
      this.index = index;
      this.$refs['date-time'].show();
    },
    /**
     * isShowToolBar：true 点击确定获取数值
     * isShowToolBar：false 滑动获取返回数据
     */
    dateTimeChange(value) {
      let item = this.list[this.index];
      item['detail'] = value;
      this.list.splice(this.index, 1, item);
    },

    confirm(e) {
      console.log(e);
      this.beginDate = e.result;
    },

    confirm2(e) {
      console.log(e);
      this.endDate = e.result;
    },

    onKeyInput_o: function(event) {
      this.subject = event.detail.value;
    },
    onKeyInput_t: function(event) {
      this.address = event.detail.value;
    },
    onKeyInput_c: function(event) {
      this.participants = event.detail.value;
    },

    onKeyInput_i: function(event) {
      this.content = event.detail.value;
    },
    onKeyInput_l: function(event) {
      this.conclusion = event.detail.value;
    },

    jsave() {
      if (!this.repeat_click) {
        return;
      }
      this.repeat_click = false;

      // if(!this.beginDate){
      // 						this.repeat_click = true;
      //uni.showToast({
      // 		title: '请输入开始时间',
      // 		icon: 'none'
      // 	})
      // 	return
      // }

      // if(!this.endDate){
      // 						this.repeat_click = true;
      //					uni.showToast({
      // 		title: '请输入结束时间',
      // 		icon: 'none'
      // 	})
      // 	return
      // }

      request({
        url: `/modor/v1/project/${
          uni.getStorageSync('dqfull_name').id
        }/meeting/minutes`,
        data: {
          address: this.address,
          beginTime: uni.getStorageSync('rq') + ' ' + that.list[0].detail,
          conclusion: this.conclusion,
          content: this.content,
          endTime: uni.getStorageSync('rq') + ' ' + that.list[1].detail,
          participants: this.participants,
          subject: this.subject,
        },

        method: 'POST',
        success: openIdRes => {
          console.log(openIdRes);
          if (openIdRes.data.success == true) {
            wx.showToast({
              title: '添加成功',
              icon: 'none',
              duration: 1000,
              success: function() {
                setTimeout(function() {
                  uni.navigateBack();
                }, 1500);
              },
            });

            // uni.navigateBack()
          } else {
            this.repeat_click = true;
            uni.showToast({
              title: openIdRes.data.msg,
              icon: 'none',
            });
            this.isLoading = false;
          }
        },
        fail: () => {
          this.repeat_click = true;
          uni.showToast({
            title: '服务器开小差，请稍后~',
            icon: 'none',
          });
          return false;
        },
      });
    },

    // 跳转
    jshow_pop() {
      this.ashowpop = !this.ashowpop;
    },
    btTC2() {
      uni.navigateTo({
        url: '../main/work_add',
      });
    },

    navigateBack() {
      uni.navigateBack();
    },
  },
  computed: {
    indicatorStyle() {
      return {
        background: 'rgba(255,0,0,.2)',
        height: '40px',
      };
    },
  },
};
</script>

<style>
.tophr {
  width: 100%;
  height: 88rpx;
}
.uni-searchbar {
  box-shadow: none;
}

.at {
  width: 160rpx;
  height: 160rpx;
  display: block;
  float: left;
  margin: 0rpx 0 0 0;
}
.att {
  width: 720rpx;
  margin: 0 0 30rpx 30rpx;
  height: auto;
  display: block;
  float: left;
  background: #ffffff;
}

.addb_1 {
  width: 720rpx;
  margin: 20rpx 30rpx 20rpx 30rpx;
  font-size: 32rpx;
  line-height: 4r0px;
  color: #000000;
  height: auto;
  display: block;
  float: left;
}
.addb_2 {
  width: 720rpx;
  margin: 0rpx 30rpx 20rpx 30rpx;
  font-size: 32rpx;
  line-height: 4r0px;
  color: #666666;
  height: auto;
  display: block;
  float: left;
}

.ptt {
  width: 100%;
  height: auto;
  display: block;
  float: left;
  background: #ffffff;
  border: 1px solid #dddddd;
  border-left: 0;
  border-right: 0;
  margin: 20rpx 0 0;
}
.pttl {
  width: 84rpx;
  height: 84rpx;
  display: block;
  float: left;
  margin: 18rpx 20rpx 18rpx 30rpx;
}
.pttr {
  width: 400rpx;
  height: 84rpx;
  display: block;
  float: left;
  margin: 18rpx 0rpx 0rpx 0rpx;
}
.pttrt {
  width: 100%;
  height: 42rpx;
  line-height: 42rpx;
  display: block;
  float: left;
  font-size: 34rpx;
  color: #000000;
}
.pttrf {
  width: 100%;
  height: 42rpx;
  line-height: 42rpx;
  display: block;
  float: left;
  font-size: 24rpx;
  color: #999999;
}
.pttjt {
  width: 16rpx;
  height: 25rpx;
  display: block;
  float: right;
  margin: 48rpx 30rpx 0 30rpx;
}
.ptf {
  width: 100%;
  height: auto;
  display: block;
  float: left;
  background: #ffffff;
  border: 1px solid #dddddd;
  border-left: 0;
  border-right: 0;
  margin: 20rpx 0 0;
}
.ptft {
  width: 720rpx;
  margin: 0 0 0 30rpx;
  height: 90rpx;
  display: block;
  float: left;
  background: #ffffff;
}
.ptft image {
  width: 48rpx;
  height: 48rpx;
  display: block;
  float: left;
  margin: 21rpx 20rpx 0 0rpx;
}
.ptft text {
  width: auto;
  height: 48rpx;
  display: block;
  float: left;
  margin: 21rpx 20rpx 0 0rpx;
  font-size: 34rpx;
  line-height: 48rpx;
  color: #000000;
}

.addi2 {
  width: 720rpx;
  margin: 0 0 0 30rpx;
  height: 90rpx;
  display: block;
  float: left;
  background: #ffffff;
  border-bottom: 1px solid #dddddd;
}
.addi {
  width: 100%;
  height: auto;
  display: block;
  float: left;
  background: #ffffff;
  box-shadow: inset 0px 1px 0px #dddddd, inset 0px -1px 0px #dddddd;
  margin: 20rpx 0 0;
}
.addi2 text {
  width: 200rpx;
  height: 90rpx;
  display: block;
  float: left;
  line-height: 90rpx;
  font-size: 34rpx;
  color: #000000;
  margin: 0 0 0 0rpx;
}
.addi text {
  width: 200rpx;
  height: 90rpx;
  display: block;
  float: left;
  line-height: 90rpx;
  font-size: 34rpx;
  color: #000000;
  margin: 0 0 0 30rpx;
}
.addi input,
.addi2 input {
  width: auto;
  height: 50rpx;
  display: block;
  float: left;
  margin: 20rpx 30rpx 0 0;
  text-align: left;
  line-height: 50rpx;
  font-size: 34rpx;
  color: #000000;
}
.addb {
  width: 100%;
  height: auto;
  display: block;
  float: left;
  background: #ffffff;
  border: 1px solid #dddddd;
  border-left: 0;
  border-right: 0;
  margin: 20rpx 0 0;
}
.addbi {
  width: 720rpx;
  margin: 0 0 0 30rpx;
  height: 90rpx;
  display: block;
  float: left;
  background: #ffffff;
  border-bottom: 1px solid #dddddd;
}
.addb .addbi:last-child {
  border: none;
}
.addbi .addbil {
  width: 200rpx;
  height: 90rpx;
  display: block;
  float: left;
  line-height: 90rpx;
  font-size: 34rpx;
  color: #000000;
}
.addbi .addbir {
  width: auto;
  height: 90rpx;
  display: block;
  float: left;
  line-height: 90rpx;
  font-size: 32rpx;
  color: #000000;
}
.addbi image {
  width: 16rpx;
  height: 25rpx;
  display: block;
  float: right;
  margin: 33rpx 30rpx 0 30rpx;
}
.addi textarea {
  width: 690rpx;
  height: 150rpx;
  display: block;
  float: left;
  margin: 0rpx 30rpx 20rpx;
  text-align: left;
  line-height: 40rpx;
  font-size: 34rpx;
  color: #000000;
}

.index {
  background: rgb(242, 242, 242);
  width: 100%;
  height: auto;
}
.jtop {
  width: 100%;
  height: 88rpx;
  background: #ffffff;
  position: fixed;
  top: 0;
  left: 0;
  z-index: 1000;
  box-shadow: inset 0px -1px 0px #dddddd;
}
.jtop_l {
  width: auto;
  height: 88rpx;
  display: block;
  float: left;
  font-size: 32rpx;
  color: #000000;
  line-height: 88rpx;
  margin: 0 0 0 30rpx;
}
.jtop_l image {
  width: 48rpx;
  height: 48rpx;
  display: block;
  float: left;
  margin: 20rpx 0 20rpx 0;
}
.jtop_lt {
  margin: 0 0 0 10rpx;
}
.jtop_r {
  width: 48rpx;
  height: 48rpx;
  display: block;
  float: right;
  margin: 20rpx 20rpx 0 0;
}
.jtop_rl {
  margin: 20rpx 30rpx 0 0;
}
.jtop_r image {
  width: 48rpx;
  height: 48rpx;
  display: block;
  float: left;
}
.jtop_c {
  width: 70%;
  height: 48rpx;
  line-height: 48rpx;
  display: block;
  float: left;
  position: fixed;
  top: 20rpx;
  left: 15%;
  text-align: center;
  font-size: 36rpx;
  color: #000000;
}
.jtop_c image {
  width: 36rpx;
  height: 36rpx;
  display: inline-block;
  float: none;
  margin-bottom: -5rpx;
  margin-left: 5rpx;
}
.jtop_b {
  width: 100%;
  height: auto;
  background: #ffffff;
  position: fixed;
  top: 88rpx;
  left: 0;
  z-index: 1001;
}
.jtop_r {
  width: auto;
  height: 88rpx;
  display: block;
  float: right;
  margin: 0rpx 20rpx 0 0;
  line-height: 88rpx;
  font-size: 32rpx;
  color: #000000;
  color: #256aff;
}
.doc_b22 {
  opacity: 0.5;
}

.nd {
  width: 735rpx;
  height: auto;
  display: block;
  float: left;
  margin: 0 0 0 0rpx;
}
.nd_bt {
  width: auto;
  height: 48rpx;
  display: block;
  float: right;
  border: 1px solid #dddddd;
  border-radius: 24rpx;
  margin: 40rpx 0 40rpx 30rpx;
}
.nd_bt text {
  width: auto;
  height: 48rpx;
  display: block;
  float: left;
  margin: 0 7rpx 0 18rpx;
  line-height: 48rpx;
  color: #666666;
  font-size: 24rpx;
}
.nd_bt image {
  width: 13rpx;
  height: 8rpx;
  display: block;
  float: left;
  margin: 21rpx 14rpx 0 0;
}

.tc {
  width: 100%;
  height: 100%;
  position: fixed;
  top: 0;
  left: 0;
  z-index: 10000;
  display: block;
}
.jtop_bj {
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  position: fixed;
  top: 0;
  left: 0;
  z-index: 10000;
}
.tc_fbox_bt {
  width: 100%;
  height: 90rpx;
  line-height: 90rpx;
  display: block;
  float: left;
  text-align: center;
  font-size: 36rpx;
  color: #000000;
  border-top: 20rpx solid #f2f2f2;
  background: #ffffff;
}
.tc_fbox {
  width: 100%;
  height: auto;
  display: block;
  float: left;
  background: #f2f2f2;
  position: fixed;
  left: 0;
  bottom: 0;
  z-index: 10001;
}
.tc_fbox_bt2 {
  width: 100%;
  height: 90rpx;
  line-height: 90rpx;
  display: block;
  float: left;
  text-align: center;
  font-size: 36rpx;
  color: #000000;
  border-top: 0rpx solid #f2f2f2;
  background: #ffffff;
}
.tc_fbox_bt3 {
  width: 100%;
  height: 90rpx;
  line-height: 90rpx;
  display: block;
  float: left;
  text-align: center;
  font-size: 36rpx;
  color: #000000;
  border-bottom: 1px solid #dddddd;
  background: #ffffff;
}

.addi2 image {
  width: 16rpx;
  height: 25rpx;
  display: block;
  float: right;
  margin: 33rpx 30rpx 0 30rpx;
}

.uni-picker-view-indicator {
  background: none !important;
}

.time-picker-tool * {
  font-size: 32rpx !important;
}
.tool-title {
  display: none !important;
}
.date-time-picker .date-time-container .time-picker-tool .confirm-btn {
  color: #007aff !important;
}

.noborder {
  margin-bottom: 0 !important;
}
</style>
